<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/conformanceFunction.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:reg="http://xbrl.org/2008/registry"
  xmlns:fcn="http://xbrl.org/2008/function"
  xmlns:cfcn="http://xbrl.org/2008/conformance/function"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:concept="http://xbrl.org/formula/conformance/example" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  http://xbrl.org/2008/conformance ../schemas/conformance.xsd
  http://xbrl.org/2008/conformance/function ../schemas/conformanceFunction.xsd
  ">
  <owners>
    <reg:owner id="geoff">
      <reg:name>Geoff Shuetrim</reg:name>
      <reg:affiliation>Galexy</reg:affiliation>
      <reg:email>geoff@galexy.net</reg:email>
     <reg:assumedOwnership moment="2008-08-22T00:00:00" />
    </reg:owner>
    <reg:owner id="herm">
      <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
      <reg:email>fischer@markv.com</reg:email>
     <reg:assumedOwnership moment="2008-09-01T15:22:00" />
    </reg:owner>
  </owners>

  <number>90106</number>

  <name>All tests</name>

  <documentation>
    <xhtml:p color="red">
      No tests have been created for this test case yet.
    </xhtml:p>
  </documentation>

  <variation id="V-01">
    <name>Works for an instance with one fact.</name>
    <documentation>
      <xhtml:p>
        Tests that the function returns the correct facts for an instance with one fact.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="facts-in-instance.xsd"/>
      <instance readMeFirst="true" id="V01" xlink:type="simple" xlink:href="one-fact-instance.xml"/>
      <cfcn:call file="V01">
        xfi:non-nil-facts-in-instance(/xbrli:xbrl)
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         count( $result ) eq 1
			and
         local-name( $result ) eq 'c1'
			and
         namespace-uri( $result ) eq 'http://xbrl.org/formula/conformance/example'
			and
         $result instance of element(concept:c1,xs:string)
         	and
         data( $result ) instance of xs:string
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-02">
    <name>Works for an instance with no facts.</name>
    <documentation>
      <xhtml:p>
        Tests that the function returns the correct facts for an instance with no facts.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="facts-in-instance.xsd"/>
      <instance readMeFirst="true" id="V02" xlink:type="simple" xlink:href="empty-instance.xml"/>
      <cfcn:call file="V02">
        xfi:non-nil-facts-in-instance(/xbrli:xbrl)
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         count( $result ) eq 0
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-03">
    <name>Works for an instance with several facts.</name>
    <documentation>
      <xhtml:p>
        Tests that the function returns the correct facts for an instance with one fact.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="facts-in-instance.xsd"/>
      <instance readMeFirst="true" id="V03" xlink:type="simple" xlink:href="three-fact-instance.xml"/>
      <cfcn:call file="V03">
        xfi:non-nil-facts-in-instance(/xbrli:xbrl)
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         count( $result ) eq 3 and
         (every $node in $result satisfies 
           $node instance of element(concept:c1,xs:string) and
           data($node) instance of xs:string)
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-04">
    <name>Works for an instance with tuples.</name>
    <documentation>
      <xhtml:p>
        Tests that the function returns the correct facts for an instance with tuples.  This instance includes
        nil tuples and tuples within tuples and items within tuples.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="facts-in-instance.xsd"/>
      <instance readMeFirst="true" id="V04" xlink:type="simple" xlink:href="tuple-instance.xml"/>
      <cfcn:call file="V04">
        xfi:non-nil-facts-in-instance(/xbrli:xbrl)
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         count( $result ) eq 5 and
         (every $node in $result satisfies 
          if (local-name($node) eq 'c1') 
          then data($node) instance of xs:string
          else true())
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-05">
    <name>Works for an instance with several facts and nil fact.</name>
    <documentation>
      <xhtml:p>
        Tests that the function returns the correct facts for an instance with one fact, including the nil fact.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="facts-in-instance.xsd"/>
      <instance readMeFirst="true" id="V05" xlink:type="simple" xlink:href="three-and-nil-fact-instance.xml"/>
      <cfcn:call file="V05">
        xfi:non-nil-facts-in-instance(/xbrli:xbrl)
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         (: count non-nil facts :)
         count( for $fact in $result return 
                   if (nilled($fact)) then ()
                   else true() 
              ) eq 3 
         and
         (: count nil facts :)
         count( for $fact in $result return 
                   if (nilled($fact)) then true()
                   else () 
              ) eq 0 
      </cfcn:test>
    </outputs>
  </variation>


  <variation id="V-06">
    <name>Works for an instance with facts of different data types.</name>
    <documentation>
      <xhtml:p>
        Tests that the function returns the correct facts for an instance with one fact, including the nil fact,
        and that each has proper type and PSVI atomicity type for typed operations.
      </xhtml:p>
     </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="facts-in-instance.xsd"/>
      <instance readMeFirst="true" id="V06" xlink:type="simple" xlink:href="multiple-types-instance.xml"/>
      <cfcn:call file="V06">
        xfi:non-nil-facts-in-instance(/xbrli:xbrl)
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         count( $result ) eq 4 and
         (every $node in $result satisfies 
          if ($node/@id eq 'a')
          then ($node instance of element(concept:c1,xs:string) and
                data($node) instance of xs:string)
          else if ($node/@id eq 'b') 
          then ($node instance of element(concept:i1,xs:integer) and
                data($node) instance of xs:integer and
                $node+1 eq 12346)
          else if ($node/@id eq 'c') 
          then ($node instance of element(concept:d1) and
                data($node) instance of xs:date and
                $node eq xs:date('2007-12-31'))
          else if ($node/@id eq 'd') 
          then ($node instance of element(concept:d1) and
                data($node) instance of xs:dateTime and
                $node eq xs:dateTime('2007-12-31T12:30:40'))
          else false())
      </cfcn:test>
    </outputs>
  </variation>

  <revisions>
    <reg:revision on="2008-01-30T00:00:00" by="geoff">
      <xhtml:p>
        Created the test case.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-09-01T00:00:00" by="herm">
      <xhtml:p>
        Added variation with nils.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-12-05T00:00:00" by="herm">
      <xhtml:p>
        Added variations with integer and dateUnion, added data type verification.
      </xhtml:p>
    </reg:revision>
  </revisions>
  
</testcase>
